package com.taotrade.nexus.admin.controller;

import com.crt.nexus.core.constant.SecurityConstants;
import com.crt.nexus.core.response.R;
import com.crt.nexus.domain.dtos.UserDto;
import com.taotrade.nexus.admin.service.UserRemoteService;
import lombok.RequiredArgsConstructor;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RefreshScope
@RestController
@RequiredArgsConstructor
@RequestMapping("/feign")
public class FeignController {

    private final UserRemoteService userRemoteService;

    @GetMapping("{username}")
    public R<UserDto> getUser(@PathVariable("username") String username) {
        return userRemoteService.getUser(username, SecurityConstants.FROM_IN);
    }

}
